package ar.uba.dc.cmovil.tripplanner.domain;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by gbarbuto on 9/24/13.
 */
public class Place implements Serializable {

	private String name;
	private Date arrivalDate;
	private Location location;

	public Place(String name, Date arrivalDate) {
		this(name, arrivalDate, NullLocation.getInstance());
	}

	public Place(String name, Date arrivalDate, Location location) {
		this.setName(name);
		this.setArrivalDate(arrivalDate);
		this.setLocation(location);
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		if (name == null) {
			throw new IllegalArgumentException("name cannot be null");
		}

		String trimmedName = name.trim();

		if (trimmedName.isEmpty()) {
			throw new IllegalArgumentException("name cannot be empty");
		}

		this.name = trimmedName;
	}

	public Date getArrivalDate() {
		return this.arrivalDate;
	}

	public void setArrivalDate(Date arrivalDate) {
		if (arrivalDate == null) {
			throw new IllegalArgumentException("arrivalDate cannot be null");
		}

		this.arrivalDate = arrivalDate;
	}

	public Location getLocation() {
		return this.location;
	}

	public void setLocation(Location location) {
		this.location = location;
	}
}
